package test;

/**
 * @description:
 * @className: TenuringThreshold
 * @package: test
 * @author: qiufeng@hsyuntai.com
 * @date: 2019/5/14 17:49
 * @copyright: 版权归 HSYUNTAI 所有
 */
public class TenuringThreshold {

    private static final int _1MB = 1024 * 1024;

    /**
     * VM参数：-XX:+UseSerialGC -verbose:gc -Xms20M -Xmx20M -Xmn10M -XX:+PrintGCDetails -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=1 -XX:+PrintTenuringDistribution
     * -XX:+PrintTenuringDistribution
     * 3-7
     */
    @SuppressWarnings("unused")
    public static void testTenuringThreshold() {
        byte[] allocation1, allocation2, allocation3;
        allocation1 = new byte[_1MB / 4];  // 什么时候进入老年代决定于XX:MaxTenuringThreshold设置，书中JDK版本为7u6，之后版本可能做出改动导致此值不生效
        allocation2 = new byte[7 * _1MB];
        allocation3 = new byte[3 * _1MB];
    }

    public static void main(String[] args) {
        TenuringThreshold.testTenuringThreshold();
    }

}
